home *** CD-ROM | disk | FTP | other *** search
/ IRIX Base Documentation 2001 May / SGI IRIX Base Documentation 2001 May.iso / usr / share / catman / p_man / cat3 / perl5 / Symbol.z / Symbol
Encoding:
Text File  |  1998-10-30  |  2.6 KB  |  133 lines

  1.  
  2.  
  3.  
  4. SSSSyyyymmmmbbbboooollll((((3333))))                                                            SSSSyyyymmmmbbbboooollll((((3333))))
  5.  
  6.  
  7.  
  8. NNNNAAAAMMMMEEEE
  9.      Symbol - manipulate Perl symbols and their names
  10.  
  11. SSSSYYYYNNNNOOOOPPPPSSSSIIIISSSS
  12.          use Symbol;
  13.  
  14.          $sym = gensym;
  15.          open($sym, "filename");
  16.          $_ = <$sym>;
  17.          # etc.
  18.  
  19.          ungensym $sym;      # no effect
  20.  
  21.          print qualify("x"), "\n";              # "Test::x"
  22.          print qualify("x", "FOO"), "\n"        # "FOO::x"
  23.          print qualify("BAR::x"), "\n";         # "BAR::x"
  24.          print qualify("BAR::x", "FOO"), "\n";  # "BAR::x"
  25.          print qualify("STDOUT", "FOO"), "\n";  # "main::STDOUT" (global)
  26.          print qualify(\*x), "\n";              # returns \*x
  27.          print qualify(\*x, "FOO"), "\n";       # returns \*x
  28.  
  29.          use strict refs;
  30.          print { qualify_to_ref $fh } "foo!\n";
  31.          $ref = qualify_to_ref $name, $pkg;
  32.  
  33.  
  34. DDDDEEEESSSSCCCCRRRRIIIIPPPPTTTTIIIIOOOONNNN
  35.      Symbol::gensym creates an anonymous glob and returns a reference to it.
  36.      Such a glob reference can be used as a file or directory handle.
  37.  
  38.      For backward compatibility with older implementations that didn't support
  39.      anonymous globs, Symbol::ungensym is also provided.  But it doesn't do
  40.      anything.
  41.  
  42.      Symbol::qualify turns unqualified symbol names into qualified variable
  43.      names (e.g. "myvar" -> "MyPackage::myvar").  If it is given a second
  44.      parameter, qualify uses it as the default package; otherwise, it uses the
  45.      package of its caller.  Regardless, global variable names (e.g. "STDOUT",
  46.      "ENV", "SIG") are always qualfied with "main::".
  47.  
  48.      Qualification applies only to symbol names (strings).  References are
  49.      left unchanged under the assumption that they are glob references, which
  50.      are qualified by their nature.
  51.  
  52.      Symbol::qualify_to_ref is just like Symbol::qualify except that it
  53.      returns a glob ref rather than a symbol name, so you can use the result
  54.      even if use strict 'refs' is in effect.
  55.  
  56.  
  57.  
  58.  
  59.  
  60.  
  61.  
  62.  
  63.                                                                         PPPPaaaaggggeeee 1111
  64.  
  65.  
  66.  
  67.  
  68.  
  69.  
  70. SSSSyyyymmmmbbbboooollll((((3333))))                                                            SSSSyyyymmmmbbbboooollll((((3333))))
  71.  
  72.  
  73.  
  74.  
  75.  
  76.  
  77.  
  78.  
  79.  
  80.  
  81.  
  82.  
  83.  
  84.  
  85.  
  86.  
  87.  
  88.  
  89.  
  90.  
  91.  
  92.  
  93.  
  94.  
  95.  
  96.  
  97.  
  98.  
  99.  
  100.  
  101.  
  102.  
  103.  
  104.  
  105.  
  106.  
  107.  
  108.  
  109.  
  110.  
  111.  
  112.  
  113.  
  114.  
  115.  
  116.  
  117.  
  118.  
  119.  
  120.  
  121.  
  122.  
  123.  
  124.  
  125.  
  126.                                                                         PPPPaaaaggggeeee 2222
  127.  
  128.  
  129.  
  130.  
  131.  
  132.  
  133.